﻿<%@ Page Title="设备管理" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="DeviceArrange.aspx.cs" Inherits="Howork.DeviceArrange" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript" src="Scripts/WdatePicker.js"></script>
    <script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
    <script type="text/javascript" src="Scripts/meeting.js"></script>
    <style type="text/css">
        input.book_button
        {
            background-color:#3DBEC9;
            width:50px;
            }
        tr.table_head
        {
            background-color:#C6AFF3;
            height:50px;
          }
        table.device_table
        {
            width:300px;
            margin-left:100px;
            margin-top:10px;
            }
        
    </style>
    <script type="text/javascript">
        $("document").ready(function () {
            $("#book").hide();
            $("#deviceDiv").
            $("#query_device").mouseup(function () {
                var begin_time = $("#text_begin").val();
                var end_time = $("#text_end").val();
                var device_type = $("#device_type").val();
                if (begin_time == "")
                    alert("请选择开始时间");
                else if (end_time == "")
                    alert("请选择结束时间");
                else if (device_type == "")
                    alert("请选择设备种类");
                else {

                    $("#book").show();
                    $.ajax({
                        url: "Ajax/QueryDevice.aspx",
                        type: "post",
                        dataType: "json",
                        data: { begin: begin_time, end: end_time, type: device_type },
                        success: function (msg) {
                            $("table tr:gt(0)").remove();
                            $(msg).each(function () {
                                var id = this.id;
                                var button = "<input type='button' class='book_button' id=" + id + " value='预订'></input>";
                                var row = "<tr id=" + id + "><td align='center'>" + this.id + "</td><td align='center'>" + this.device_name + "</td><td align=center>" + button + "</td></tr>";
                                var row_num = $("table tr").size() - 1;
                                $(row).insertAfter($("table tr:eq(0)"));
                            })
                            $("input[type='button'].book_button").mouseup(function () {
                                var user_id = $("#user_id").val();
                                if (user_id == "")
                                    alert("请输入待借用户ID");
                                else {
                                    var id = $(this).attr("id");
                                    $.ajax({
                                        url: "Ajax/BookDevice.aspx",
                                        type: "post",
                                        data: { id: id, begin: begin_time, end: end_time, userid: user_id },
                                        success: function (msg) {
                                            alert(msg);
                                            $("tr#" + id + "").remove();
                                        }
                                    })
                                }

                            })
                        }
                    });
                }
            });
        });
        function query_room_onclick() {

        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div id="query">
    <label>开始时间</label> 
    <input id="text_begin" type="text" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"></input>
    <label>结束时间</label>
    <input id="text_end" type="text" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"></input>
    <label>设备类型</label>
    <select name="selectDropDown" id="device_type">
        <option>1</option>
        <option>2</option>
        <option>3</option>
        <option>4</option>
        <option>5</option>
    </select>
    <input id="query_device" type="button" style="{background-color:White}" value="查询" onclick="return query_room_onclick()">
 </div> 
 <div id="book">
    <div style="margin-top: 10px">
    <label id="borrower">待借用户</label>
    <input id="user_id" type="text"></input>
    <label>设备列表：</label>
    <table class="device_table" title="设备列表">
        <tr class="table_head">
        <th style="{width:100px}">设备号</th>
        <th style="{width:100px}">设备名称</th>
        <th style="{width:100px}">预订</th>
        </tr>
    </table>
    </div>
 </div>
</asp:Content>

